﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using PrinterBudi.Persistence;

namespace PrinterBudi.Desktop
{
    public partial class FormAddEmployee : Form
    {
        public FormAddEmployee()
        {
            InitializeComponent();
        }

        private void btnSubmitEmployee_Click(object sender, EventArgs e)
        {
            if (PBEmployeeModel.Create(tbPhoneNumberEmployee.Text, tbNameEmployee.Text, tbNameEmployee.Text))
            {
                MessageBox.Show("Success!");
                this.Close();
            }
            else
            {
                if (PBEmployeeModel.Read(tbPhoneNumberEmployee.Text) != null)
                    MessageBox.Show("Employee already exists!");
                else
                    MessageBox.Show("Failed!");
            }
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
